package com.CMS.server.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import com.CMS.server.domain.ItemMenu;
import com.CMS.server.domain.Menu;

public class ItemMenuDao extends BaseDao<ItemMenu>{
	
	public ItemMenuDao(){
		super();
	}
	
	@SuppressWarnings("unchecked")
	public List<ItemMenu> getChilds(ItemMenu parent, Menu menu){
		EntityManager em = entityManager();	
		List<ItemMenu> lista = null;
		try{			
			Query q  = em.createQuery("select u from ItemMenu u "+ 
									  "where u.padre = ?1 and u.menu = ?2");
			q.setParameter(1, parent);
			q.setParameter(2, menu);
			lista = q.getResultList();
		}
		finally{
			em.close();
		}
		return lista;
	}

}
